package com.web.dao;

import com.web.entity.Bank;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

/**
 * @author FDjavaone
 */
public class BankSqlProvider {


    public String insertSelective(Bank record) {
        BEGIN();
        INSERT_INTO("t_bank");

        if (record.getmId() != null) {
            VALUES("m_id", "#{mId,jdbcType=BIGINT}");
        }

        if (record.getName() != null) {
            VALUES("name", "#{name,jdbcType=VARCHAR}");
        }

        if (record.getCardNo() != null) {
            VALUES("card_no", "#{cardNo,jdbcType=VARCHAR}");
        }

        if (record.getPhone() != null) {
            VALUES("phone", "#{phone,jdbcType=VARCHAR}");
        }

        if (record.getBankName() != null) {
            VALUES("bank_name", "#{bankName,jdbcType=VARCHAR}");
        }

        if (record.getCardType() != null) {
            VALUES("card_type", "#{cardType,jdbcType=VARCHAR}");
        }

        if (record.getDefaultStatus() != null) {
            VALUES("default_status", "#{defaultStatus,jdbcType=INTEGER}");
        }

        if (record.getCreateTime() != null) {
            VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }

        if (record.getModifyTime() != null) {
            VALUES("modify_time", "#{modifyTime,jdbcType=TIMESTAMP}");
        }

        return SQL();
    }


    public String updateByPrimaryKeySelective(Bank record) {
        BEGIN();
        UPDATE("t_bank");

        if (record.getmId() != null) {
            SET("m_id = #{mId,jdbcType=BIGINT}");
        }

        if (record.getName() != null) {
            SET("name = #{name,jdbcType=VARCHAR}");
        }

        if (record.getCardNo() != null) {
            SET("card_no = #{cardNo,jdbcType=VARCHAR}");
        }

        if (record.getPhone() != null) {
            SET("phone = #{phone,jdbcType=VARCHAR}");
        }

        if (record.getBankName() != null) {
            SET("bank_name = #{bankName,jdbcType=VARCHAR}");
        }

        if (record.getCardType() != null) {
            SET("card_type = #{cardType,jdbcType=VARCHAR}");
        }

        if (record.getDefaultStatus() != null) {
            SET("default_status = #{defaultStatus,jdbcType=INTEGER}");
        }

        if (record.getCreateTime() != null) {
            SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }

        if (record.getModifyTime() != null) {
            SET("modify_time = #{modifyTime,jdbcType=TIMESTAMP}");
        }

        WHERE("id = #{id,jdbcType=BIGINT}");

        return SQL();
    }


}